﻿using OpenCvSharp;
using OpenCvSharp.Extensions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OpenCV
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
           
        }

        private void trackBar1_ValueChanged(object sender, EventArgs e)
        {
            Flann();
        }
        public void Flann()
        {
            var img1 = new Mat("F:/1.jpg");//# 查询图像（target）
            var img2 = new Mat("F:/4.jpg");// # 训练图像（train）
            var des1 = OpenCVHelper.GetSURF(img1);
            var des2 = OpenCVHelper.GetSURF(img2);
            var img3 = OpenCVHelper.GetFlann(des1, des2,(double)trackBar1.Value/(double)100);
            des1.result.SaveImage("F:/D1.png");
            des2.result.SaveImage("F:/D2.png");
            img3.SaveImage("F:/D3.png");
            Mat Result1 = OpenCVHelper.Resize(des1.result, pictureBox1.Width, pictureBox1.Height);
            pictureBox1.Image = Result1.ToBitmap();
            Mat Result2 = OpenCVHelper.Resize(des2.result, pictureBox2.Width, pictureBox2.Height);
            pictureBox2.Image = Result2.ToBitmap();
            Mat Result3 = OpenCVHelper.Resize(img3, pictureBox3.Width, pictureBox3.Height);
            pictureBox3.Image = Result3.ToBitmap();
        }
    }
}
